<?php
class Main_Module
{
    /**
     * @var array
     */
    private static $_modules;
	
    /**
     * @return array
     */
	private static function _load() 
	{
	    $moduleNames = @scandir(MODULES_PATH);
		foreach ($moduleNames as $moduleName) {
		    if (substr_count($moduleName, '.') >= 1){
		        continue;    
		    }
		    if ($moduleName != 'default') { 	    
		    	$resModules[$moduleName] = $moduleName;
		    }	
		}
		
		self::$_modules[0] = 'admin';
		foreach ($resModules as $resModule) {
			if ($resModule != 'admin') {
				self::$_modules[] = $resModule;
			}	
		}

		return self::$_modules;
	}
	
	/**
	 * @return array
	 */
	public static function getModules() 
	{
		if (null === self::$_modules){
			self::_load();	
		}
		
		return self::$_modules;
	}
} 